package plochki;

public class Figura {
	//type of Figure
	public String figuraType;
	//position of the Figure
	public int posX;
	public int posY;
	
	//Index of the Figure (in the order of the input, starting from 1)
	public int index;
	
	//Deprecated, how many other Figures overlap this one
	public int stuckLevel;
	
	//Offset from the central point
	public int leftOffset;
	public int rightOffset;
	public int upOffset;
	public int downOffset;
	
	//The minimum radius at which a place for this Figure can be found
	//Starting from 1
	public int bestMoveDistance;
	//Current Best New position for the Figure
	public int bestNewPosX;
	public int bestNewPosY;
	
	public Figura(String name, int posA, int posB, int index)
	{
		this.figuraType = name;
		this.posX = posA;
		this.posY = posB;
		
		this.index = index;
		
		this.stuckLevel = 0;
		
		this.bestMoveDistance = 1;
		
		switch(this.figuraType) {
			case"ninetile":
			case"plus":
			{
				this.upOffset = 1;
				this.downOffset = 1;
				this.leftOffset = 1;
				this.rightOffset = 1;
				break;
			}
			case"hline":
			{
				this.leftOffset = 1;
				this.rightOffset = 1;
				break;
			}
			case"vline":
			{
				this.upOffset = 1;
				this.downOffset = 1;
				break;
			}
			case"angle-ur":
			{
				this.upOffset = 1;
				this.rightOffset = 1;
				break;
			}
			case"angle-dr":
			{
				this.downOffset = 1;
				this.rightOffset = 1;
				break;
			}
			case"angle-ul":
			{
				this.upOffset = 1;
				this.leftOffset = 1;
				break;
			}
			case"angle-dl":
			{
				this.downOffset = 1;
				this.leftOffset = 1;
				break;
			}
		}
	}
	
	public String toString()
	{
		return this.figuraType + " (" + this.posX + "," + this.posY + "), level->" + this.stuckLevel;
	}
	
	public boolean equals(Object o) {
		Figura other = (Figura)o;
		
		return this.index == other.index;
	}
}
